<?php

Yii::import('zii.widgets.CListView');

class MyFilterListView extends CListView
{
	public $template="{summary}\n{pager}\n{filteropenbut}\n{filter}\n{sorter}\n{items}\n{summary}\n{pager}";
	
	public $filterCssClass="filter";
	public $filterFormCssClass="form";
	public $filterOpenButCssClass="filterTopButtons";
	
	public $cssFile="/css/filterlistview/styles.css";
	
	public function renderFilterOpenBut()
	{
		echo CHtml::openTag('ul',array('class'=>$this->filterOpenButCssClass))."\n";
		echo CHtml::openTag('li')."\n";
		echo CHtml::link(CHtml::image('http://www.yiiframework.com/forum/public/style_images/master/cog.png').' '.Yii::t('cms', 'Advanced filters'),array('#'))."\n";
		echo CHtml::closeTag('li')."\n";
		echo CHtml::closeTag('ul')."\n";
	}
	
	public function renderFilter()
	{
		$model=new FilterPacketForm;  //TODO Fix me
		
		echo CHtml::openTag('div',array('class'=>$this->filterCssClass))."<!-- $this->filterFormCssClass -->\n";
		
		echo CHtml::errorSummary($model);
		echo CHtml::openTag('div',array('class'=>$this->filterFormCssClass))."<!-- $this->filterCssClass -->\n";		
		echo CHtml::beginForm(CHtml::normalizeUrl(''),'get');
		
		echo CHtml::openTag('h3', array('class'=>'bar'));
		echo Yii::t('cms', 'Advanced Filter Options');
		echo CHtml::closeTag('h3');
		
		echo CHtml::openTag('div', array('class'=>'row'));
		echo CHtml::activeLabelEx($model,'username');
		echo CHtml::activeTextField($model,'username',array('size'=>25,'maxlength'=>25));
		echo CHtml::error($model,'username');
		echo CHtml::closeTag('div');
	
		echo CHtml::openTag('div', array('class'=>'buttons'));
		echo CHtml::submitButton(Yii::t('cms', 'Apply Filters'));
		echo Yii::t('cms'," or ");
		echo CHtml::link(Yii::t('cms', 'Cancel'),array('/user'),array("class"=>"cancel"));
		echo CHtml::closeTag('div');

		echo CHtml::endForm();
		
		echo CHtml::closeTag('div')."<!-- $this->filterFormCssClass -->\n";
		echo CHtml::closeTag('div')."<!-- $this->filterCssClass -->\n";
	}
}